package satir.framework.refectoring;

import org.json.JSONObject;

/**
 * The Interface Factory.
 * @version 3.0 April 2012
 * @author Creative Family
 */
public interface Factory {

    /**
     * Creates the.
     * @param json
     *            the json
     * @return the object
     * @throws FactoryException
     *             the factory exception
     */
    Object create(JSONObject json) throws FactoryException;

    /**
     * The Class FactoryException.
     */
    public class FactoryException extends Exception {

	/**
	 * Instantiates a new factory exception.
	 * @param message
	 *            the message
	 */
	public FactoryException(final String message) {
	    super(message);
	}
    }

    /**
     * The Class FactoryCreateInstantiationFailureException.
     */
    public class FactoryCreateInstantiationFailureException extends
	    FactoryException {

	/**
	 * Instantiates a new factory create instantiation failure exception.
	 * @param target
	 *            the target
	 * @param factory
	 *            the factory
	 */
	public FactoryCreateInstantiationFailureException(final String target, final Factory factory) {
	    super(
		    "ERROR: Create instanitation from JSON failure. Reference: Factory ["
			    + factory.getClass().toString()
			    + "], Instantiation [" + target + "]");
	}
    }
}
